package com.xxl.job.executor.service.jobhandler;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import com.xxl.job.executor.process.AutomaticControlModbusTcpProcess;
import org.springframework.stereotype.Component;

/**
 * 环控采集
 *
 * @author wang.kunlin
 * @date 2020年03月17日 16:05
 */
@JobHandler(value="automaticControlModbusTcpJobHandler")
@Component
public class AutomaticControlModbusTcpJobHandler extends IJobHandler {
    @Override
    public ReturnT<String> execute(String param)  throws Exception{

        //判断入参数据合法性
        if (param.length() < 7) {
            XxlJobLogger.log("非法采集口号，程序退出");
            return FAIL;
        }
        XxlJobLogger.log("====Start Collect Job,GatherID:" + param + "====");

        AutomaticControlModbusTcpProcess automaticControlModbusTcpProcess=new AutomaticControlModbusTcpProcess(param);
        automaticControlModbusTcpProcess.collectProcess();

        return SUCCESS;
    }
}
